package com.service.impl;

import com.bean.Completed;
import com.dao.CompletedDao;
import com.service.CompletedService;
import com.utils.PageBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class CompletedServiceImpl implements CompletedService {
    @Resource
    CompletedDao completedDao;
    @Override
    public List<Completed> completedList() {
        return completedDao.completedList();
    }

    @Override
    public void addCompleted(int id, String username, String question, String contact, String address, Date date, String accender_name, String sender) {
        completedDao.addCompleted(id, username, question, contact, address, date, accender_name, sender);
    }

    @Override
    public PageBean findByPage(int pageNo, int pageSize) {
        PageBean pageBean = new PageBean();
        pageBean.setList(completedDao.findByPage((pageNo-1)*pageSize, pageSize));
        pageBean.setPageNo(pageNo);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecords(completedDao.getTotalPages());
        return pageBean;
    }
}
